package asteroids.model.programs.expressions.BasicExpressions;

import be.kuleuven.cs.som.annotate.Basic;
import asteroids.model.programs.expressions.BasicExpression;
import asteroids.model.programs.types.Type;
 /**
  * Class representing Boolean literals
  * 
  * @author Lennart De Graef
  *
  */

public class BooleanLiteral extends BasicExpression {
	
	/**
	 * Initialize this new boolean literal with given value.
	 *
	 * @param  value
	 *         The value for this new boolean literal.
	 * @post   The value of this new boolean literal is equal to
	 *         the given value.
	 *       | new.getValue() == value
	 */
	public BooleanLiteral(boolean value, int line, int column){
		super(line, column);
		this.value = value;
	}
	
	/**
	 * Return the value of this boolean literal.
	 * @return ...
	 * 			this.value
	 */
	@Basic
	public boolean getValue(){
		return this.value;
	}
	
	/**
	 * Sets the value of this Boolean to the given literal
	 * 
	 * @param newValue
	 * 		  The new value of the boolean literal
	 * @post ...
	 * 		 (new this).getValue() == newValue
	 */
	@Basic
	public void SetValue(boolean newValue){
		value = newValue;
	}
	
	private boolean value;
	
	/**
	 * @return the textual form of this expression
	 * 			| if(value)
	 * 			|	return "true"
	 * 			| else
	 * 			|	return "false"
	 */
	@Override
	public String toString() {
		return String.valueOf(value);
	}
	
	/**
	 * @return Returns this expression
	 * 			| return this
	 */
	@Override
	public BasicExpression getResult() {
		return this;
	}
	
	@Override
	public Type getType() {
		return Type.BOOLEAN;
	}

}
	
